package com.celeritymq.connection;

import java.io.IOException;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;

import javax.jms.ConnectionConsumer;
import javax.jms.ConnectionMetaData;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;
import javax.jms.ServerSessionPool;

import com.celeritymq.session.CelerityQueueSession;

public class CelerityQueueConnection extends CelerityConnectionImpl implements QueueConnection {
	private List<CelerityQueueSession> sessionList = new ArrayList<CelerityQueueSession>();
	private List<CelerityConnectionConsumer> consumerList = new ArrayList<CelerityConnectionConsumer>();

	CelerityQueueConnection(SocketAddress address, int bufferSize) throws IOException {
		super(address, bufferSize);
	}

	@Override
	public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool,
			int maxMessages) throws JMSException {
		CelerityConnectionConsumer consumer = new CelerityConnectionConsumer(queue, messageSelector, sessionPool, maxMessages);
		consumerList.add(consumer);
		return consumer;
	}

	@Override
	public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
		CelerityQueueSession session = new CelerityQueueSession(targetAddress, transacted, acknowledgeMode);
		sessionList.add(session);
		return session;
	}

}
